let li = ''
for (let i = 0; i < 50; i++) {
  li += `<li>${i + 1}</li>`
}
let list = document.querySelector('.list')
list.innerHTML = li
// 监听ul元素的滚懂操作
list.onscroll = function () {
  // 向上滑动的距离
  let scrollTop = this.scrollTop
  // 向左滑动的距离
  let scrollLeft = this.scrollLeft
  console.log(scrollTop, scrollLeft)
}
// 页面刷新前执行的操作
window.onbeforeunload = function () {
  list.scrollTo({ top: 0, left: 0, behavior: 'smooth' })
}
